package ACWing.Dynamicprogramming;
//蓝桥的二次选拔赛完全背包问题
import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/12/3 16:28
 */
public class SplicingOFOecisiveBattle {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[]arr=new int[n+1];
        for (int i = 1; i <= n; i++) {
            arr[i]=sc.nextInt();
        }
        int m=sc.nextInt();
        int[]dp=new int[m+1];
        /**
         * 最小状态的重难点在于状态的初始化。。。。。
         */
        for (int i = 1; i <= m ; i++) {//最小状态的话初始值是最大因为是可以完全放下所以dp[0]=0
            dp[i]= (int) 1E9;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = arr[i]; j <= m; j++) {
                dp[j]=Math.min(dp[j-arr[i]]+1,dp[j]);
            }
        }
        if(dp[m]==(int) 1E9){
            System.out.println(-1);
            return;
        }
        System.out.println(dp[m]);
    }

}
